package method.searchSQL;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;


public class orderTreeID {
	private String orderTreeID;
	
	public orderTreeID(){}
	
	public void setID(){
		orderTreeID = "Gundom";
		
	}
	
	
	
	public void setNewTreeID(String url){
		try {
			
			url = url+"id.php";
        	
			HttpClient client = new DefaultHttpClient();
			HttpGet request = new HttpGet(url);
			HttpResponse response = client.execute(request);

			String line = "";
			String reply = "";
			
			BufferedReader reader = new BufferedReader(
					new InputStreamReader(response.getEntity()
							.getContent()));
			while ((line = reader.readLine()) != null) {
				reply += line;
			}
			reader.close();
			try {

				orderTreeID = reply;

			} catch (Exception e) {
				orderTreeID = "Input Error! Please Check input is Correct";
			}
		} catch (Exception e) {
			orderTreeID = "Please Check network connection";
		}
	}
	
	public String getNewTreeID(){
		return orderTreeID;
	}
	
}
